package org.hotelsystem.hoteladminsystem.Service.IMP;

import org.hotelsystem.hoteladminsystem.Mapper.RoomMapper;
import org.hotelsystem.hoteladminsystem.Pojo.Room;
import org.hotelsystem.hoteladminsystem.Service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RoomServiceIMP implements RoomService {
    @Autowired
    private RoomMapper roomMapper;


    /**
     * @param hotelID
     * @return
     */
    @Override
    public Map<String, Object> getHotelRooms(Integer hotelID) {
        Map<String, Object> result = new HashMap<>();
        try {
            List<Room> rooms = roomMapper.getRoomsByHotelId(hotelID);
            result.put("result", true);
            result.put("code", "200");
            result.put("msg", "Successfully retrieved hotel rooms");
            result.put("data", rooms);
            result.put("count", rooms.size());

        } catch (Exception e) {
            e.printStackTrace();
            result.put("result", false);
            result.put("code", "500");
            result.put("msg", "后台异常，请联系管理员");
            result.put("data", null);
            result.put("count", 0);
        }
        return result;
    }




}